package com.fengze.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.fengze.common.annotation.Log;
import com.fengze.common.core.controller.BaseController;
import com.fengze.common.core.domain.AjaxResult;
import com.fengze.common.enums.BusinessType;
import com.fengze.business.domain.InquiryRecord;
import com.fengze.business.service.IInquiryRecordService;
import com.fengze.common.utils.poi.ExcelUtil;
import com.fengze.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;

/**
 * 询价记录Controller
 * 
 * @author lug
 * @date 2024-02-01
 */
@RestController
@RequestMapping("/proproject/inquiryrecord")
public class InquiryRecordController extends BaseController
{
    @Autowired
    private IInquiryRecordService inquiryRecordService;

    /**
     * 查询询价记录列表
     */
    @PreAuthorize("@ss.hasPermi('proproject:inquiryrecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(InquiryRecord inquiryRecord)
    {
        startPage();
        List<InquiryRecord> list = inquiryRecordService.selectInquiryRecordList(inquiryRecord);
        return getDataTable(list);
    }

    /**
     * 导出询价记录列表
     */
    @PreAuthorize("@ss.hasPermi('proproject:inquiryrecord:export')")
    @Log(title = "询价记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InquiryRecord inquiryRecord)
    {
        List<InquiryRecord> list = inquiryRecordService.selectInquiryRecordList(inquiryRecord);
        ExcelUtil<InquiryRecord> util = new ExcelUtil<InquiryRecord>(InquiryRecord.class);
        util.exportExcel(response, list, "询价记录数据");
    }

    /**
     * 获取询价记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('proproject:inquiryrecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(inquiryRecordService.selectInquiryRecordById(id));
    }

    /**
     * 新增询价记录
     */
    @PreAuthorize("@ss.hasPermi('proproject:inquiryrecord:add')")
    @Log(title = "询价记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(InquiryRecord inquiryRecord, MultipartFile file) throws Exception {
        return toAjax(inquiryRecordService.insertInquiryRecordWithFile(inquiryRecord,file));
    }

    /**
     * 修改询价记录
     */
    @PreAuthorize("@ss.hasPermi('proproject:inquiryrecord:edit')")
    @Log(title = "询价记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(InquiryRecord inquiryRecord,MultipartFile file) throws Exception {
        return toAjax(inquiryRecordService.updateInquiryRecordWithFile(inquiryRecord,file));
    }

    /**
     * 删除询价记录
     */
    @PreAuthorize("@ss.hasPermi('proproject:inquiryrecord:remove')")
    @Log(title = "询价记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(inquiryRecordService.deleteInquiryRecordByIds(ids));
    }
}
